package com.meal.entity.entity.base;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.meal.entity.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * <p>
 *
 * </p>
 *
 * @author yzh
 * @since 2020-05-06
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@SuperBuilder(toBuilder = true)
@EqualsAndHashCode(callSuper = true)
@TableName("t_dict")
@ApiModel(value="Dict对象", description="字典表")
public class Dict extends BaseEntity<Dict> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "字典表主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty(value = "字典表类型")
    @TableField("type")
    private Integer type;

    @ApiModelProperty(value = "字典名")
    @TableField("name")
    private String name;

    @ApiModelProperty(value = "字典值")
    @TableField("value")
    @NotNull(message = "字典值不能为空")
    @Length(max = 255, message = "字典值过长")
    private String value;

    @ApiModelProperty(value = "父主键")
    @TableField("parent_id")
    private Integer parentId;

    @ApiModelProperty(value = "排序")
    @TableField("sort")
    private Integer sort;

    @ApiModelProperty(value = "是否可用1是0否")
    @TableField("enable")
    private Boolean enable;


    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}
